/**
 * @Description: 注册所有指令
 * @Author bianpengfei
 * @create 2022/11/25 18:19
 */
import { requireAllModule, isPlainObject, kebabCase } from 'sf-utils2'
import { basename } from 'path'

export default {
  /**
   * 注册所有指令
   */
  install: (app) => {
    requireAllModule({
      requireContext: require.context('./modules', true, /\.js$/),
      exclude: ['./modules/index.js']
    }).forEach(([v, k]) => {
      if (isPlainObject(v?.default)) {
        const name = basename(k, '.js')
        app.directive(kebabCase(name), v.default)
      }
    })
  }
}
